package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishDTO;
import com.sky.dto.DishPageQueryDTO;
import com.sky.entity.Dish;
import com.sky.entity.DishFlavor;
import com.sky.enumeration.OperationType;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 分页查询
     * @param dishPageQueryDTO
     * @return
     */
    Page<DishVO> pageQuery(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 根据id查询菜品
     * @param id
     */
    @Select("select * from dish where id = #{id}")
    Dish getDishById(long id);

    /**
     * 修改菜品状态
     * @param dish
     */
    @Update("update dish set status =#{status},update_time=#{updateTime},update_user=#{updateUser} where id = #{id} ")
    void changeStatus(Dish dish);

    /**
     * 根据分类id查询菜品
     * @param id
     * @return
     */
    @Select("select * from dish where category_id = #{id}")
    List<Dish> getDishByCateId(Integer id);

    /**
     * 批量删除
     * @param ids
     */
    void deleteByIds(List<Integer> ids);

    /**
     * 新增菜品
     * @param dish
     */
    @AutoFill(value = OperationType.INSERT)
    void addDish(Dish dish);

    /**
     * 修改菜品
     * @param dish
     */
    @Update("update dish set name=#{name},category_id=#{categoryId},price=#{price},image=#{image},description=#{description},update_time=#{updateTime},update_user=#{updateUser} where id=#{id}")
    void editDish(Dish dish);

    /**
     * 动态查询菜品
     * @param dish
     * @return
     */
    List<Dish> list(Dish dish);
}
